// import { getAllRoleList, isAccountExist } from '@/api/demo/system';
import { BasicColumn, FormSchema } from '@/components/Table';
import { Tinymce } from '@/components/Tinymce';
import { h } from 'vue';
import { useI18n } from '@/hooks/web/useI18n';

const { t } = useI18n();
/**
 * transform mock data
 * {
 *  0: '华东分部',
 * '0-0': '华东分部-研发部'
 * '0-1': '华东分部-市场部',
 *  ...
 * }
 */
// export const deptMap = (() => {
//   const pDept = ['华东分部', '华南分部', '西北分部'];
//   const cDept = ['研发部', '市场部', '商务部', '财务部'];

//   return pDept.reduce((map, p, pIdx) => {
//     map[pIdx] = p;

//     cDept.forEach((c, cIndex) => (map[`${pIdx}-${cIndex}`] = `${p}-${c}`));

//     return map;
//   }, {});
// })();
//表头数据
export const columns: BasicColumn[] = [
  {
    title: '用户id',
    dataIndex: 'toId',
    width: 120,
  },
  {
    title: '用户名称',
    dataIndex: 'nickname',
    width: 120,
  },
  {
    title: '动态内容',
    dataIndex: 'content',
    width: 120,
  },
  {
    title: '发布时间',
    dataIndex: 'grade',
    width: 180,
  },
];
//表头搜素数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'toId',
    label: '商户id',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'nickname',
    label: '商户名称',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'phone',
    label: '手机号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'member',
    label: '全部地区',
    component: 'Select',
    colProps: { span: 4 },
  },
  {
    field: 'status',
    label: t('sys.analysis.columns.status'),
    component: 'Select',
    colProps: { span: 4 },
  },
];

export const accountFormSchema: FormSchema[] = [
  {
    field: 'classifyId',
    component: 'Select',
    label: t('sys.video.columns.classifyId'),
    colProps: {
      span: 12,
    },
    rules: [{ required: true }],
  },
  {
    field: 'item',
    component: 'Input',
    label: t('sys.video.columns.classifyItem'),
    defaultValue: '',
    colProps: {
      span: 12,
    },
    rules: [{ required: true }],
  },
  {
    field: 'title1',
    component: 'Input',
    label: t('sys.video.columns.standardNumber'),
    defaultValue: '',
    colProps: {
      span: 12,
    },
    rules: [{ required: true }],
  },
  {
    field: 'frequency',
    component: 'Input',
    label: t('sys.video.columns.frequency'),
    defaultValue: '',
    colProps: {
      span: 12,
    },
  },
  {
    field: 'tinymce',
    component: 'Input',
    label: t('sys.video.columns.tinymce'),
    defaultValue: '',
    colProps: {
      span: 24,
    },
    rules: [{ required: true }],
    render: ({ model, field }) => {
      return h(Tinymce, {
        value: model[field],
        onChange: (value: string) => {
          model[field] = value;
        },
      });
    },
  },
];

//基础字段
export const accountFormSchemaFields: FormSchema[] = [
  {
    field: 'title',
    component: 'Input',
    label: t('sys.video.columns.submitTitel'),
    defaultValue: '',

    rules: [{ required: true }],
  },
  {
    field: 'title',
    component: 'RadioGroup',
    label: t('sys.video.columns.isPhoto'),
    defaultValue: '',
    componentProps: {
      options: [
        {
          label: t('sys.configuration.YES'),
          value: '1',
        },
        {
          label: t('sys.configuration.NO'),
          value: '2',
        },
      ],
    },

    rules: [{ required: true }],
  },
  {
    field: 'title',
    component: 'RadioGroup',
    label: t('sys.video.columns.submitType'),
    defaultValue: '',
    rules: [{ required: true }],
    componentProps: {
      options: [
        {
          label: t('sys.video.columns.trueType'),
          value: '1',
        },
        {
          label: t('sys.video.columns.selectType'),
          value: '2',
        },
        {
          label: t('sys.video.columns.selectListType'),
          value: '3',
        },
      ],
    },
  },
  {
    field: 'title',
    component: 'Input',
    label: t('sys.video.columns.configurationOptions'),
    defaultValue: '',

    rules: [{ required: true }],
  },
];
